package com.hex.ds.hdrs.period.task.service;

import com.hex.ds.hdrs.period.job.po.HisBitch;
import com.hex.ds.hdrs.period.job.service.HisBitchService;
import com.hex.ds.hdrs.period.task.dao.PeriodTaskStreamHisDao;
import com.hex.ds.hdrs.period.task.po.PeriodTaskStreamHis;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class PeriodTaskStreamHisService {

    @Autowired
    private PeriodTaskStreamHisDao periodTaskStreamHisDao;

    @Autowired
    private HisBitchService hisBitchService;

    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void insert(Map map){
        this.periodTaskStreamHisDao.insert(map);
    }

    public int qryDayCount(Map map) {
        return this.hisBitchService.qryDayCount(map);
    }

    public List<PeriodTaskStreamHis> selectList(HisBitch hisBitch){
        Map map = new HashMap();
        map.put("bitchId",hisBitch.getBitchId());
        return periodTaskStreamHisDao.selectListByBitchId(map);
    }

    public void delByBitchId(String bitchId){
        Map map = new HashMap();
        map.put("bitchId",bitchId);
        periodTaskStreamHisDao.deleteByBitchId(map);
    }
}
